
export default {
  data() {
    const pageSizes = [10, 20, 30, 50, 100]
    const perNum = pageSizes[0]

    return {
      // 分页
      pageSizes: pageSizes,
      perNum: perNum,
      currentPage: 1
    }
  },
  methods: {

    // 分页
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.perNum = val
      if (this.autoScroll) {
        scrollTo(0, 800)
      }
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.currentPage = val
      if (this.autoScroll) {
        scrollTo(0, 800)
      }
    }

  },
  computed: {
    // 分页
    currentList() {
      const arr = []
      for (let i = this.perNum * (this.currentPage - 1); i < this.perNum * this.currentPage && i < this.tableData.length; i++) {
        arr.push(this.tableData[i])
      }

      return arr
    },
    total() {
      return this.tableData.length
    }
  }
}
